package com.th.supcom.pds.internal.server;

import net.carefx.framework.container.client.exception.UiException;
import net.carefx.framework.util.ConvertUtils;
import net.carefx.framework.web.gwt.server.GwtController;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.th.supcom.pds.domain.vo.PatientInfo;
import com.th.supcom.pds.internal.api.MedicalCardService;
import com.th.supcom.pds.internal.client.model.PatientInfoModel;
import com.th.supcom.pds.internal.client.service.MedicareCardRpc;

public class MedicareCardServiceController extends GwtController implements MedicareCardRpc
{

    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, TH Supcom Corporation";
    /** 日志记录器. */
    public static Logger s_logger = LoggerFactory.getLogger (MedicareCardServiceController.class);

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

    private static final long serialVersionUID = 2982602394570988200L;

    private MedicalCardService m_medicalCardService;

    @Override
    public PatientInfoModel getMedicareAllCard (final String trackData, final String indentityType,
                                                final String prescSource) throws UiException
    {
        try
        {
            // 获取就诊卡信息
            final PatientInfo medicareCardInfo = m_medicalCardService.getCardInfo (trackData, indentityType,
                                                                                   prescSource);
            PatientInfoModel patientInfoModel = ConvertUtils.convert (PatientInfoModel.class, medicareCardInfo);
            return patientInfoModel;
        }
        catch (final Exception ex)
        {
            throw new UiException (ex.getMessage (), ex);
        }

    }

    public void setMedicalCardService (final MedicalCardService medicalCardService)
    {
        this.m_medicalCardService = medicalCardService;
    }

}
